package com.exam.role.service.impl;

import com.exam.role.dao.StudentDao;
import com.exam.role.dao.TeacherDao;
import com.exam.role.model.User;
import com.exam.role.service.LoginService;

public class LoginServiceImpl implements LoginService {
	private StudentDao studentDao;
	private TeacherDao teacherDao;

	public TeacherDao getTeacherDao() {
		return teacherDao;
	}

	public void setTeacherDao(TeacherDao teacherDao) {
		this.teacherDao = teacherDao;
	}

	public void setStudentDao(StudentDao studentDao) {
		this.studentDao = studentDao;
	}

	public StudentDao getStudentDao() {
		return studentDao;
	}

	public User getUser(User user) {
		if (user.isStudent()) {
			return studentDao.getStudent(user.getUname());
		} else if (user.isTeacher()) {
			return teacherDao.getTeacher(user.getUname());
		}
		return null;
	}

}
